package main.java.com.manger.controller;

import com.manger.constant.Constant;
import com.manger.dto.Login;
import com.manger.entity.Student;
import com.manger.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;

/**
 * Created by LCJ on 2017/6/15.
 */
@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public String login(){
        return "login";
    }
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(Login login,HttpSession session ){
        if(loginService.login(login,session) instanceof Student){
            return Constant.PAGE_ADMIN;
        }
        return "login";
    }
}
